package com.ruoyi.ncpsy.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.ncpsy.domain.NcpsyWareInfo;
import com.ruoyi.ncpsy.service.INcpsyWareInfoService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 仓储信息Controller
 * 
 * @author ruoyi
 * @date 2025-11-13
 */
@RestController
@RequestMapping("/ncpsy/wareinfo")
public class NcpsyWareInfoController extends BaseController
{
    @Autowired
    private INcpsyWareInfoService ncpsyWareInfoService;

    /**
     * 查询仓储信息列表
     */
    @PreAuthorize("@ss.hasPermi('ncpsy:wareinfo:list')")
    @GetMapping("/list")
    public TableDataInfo list(NcpsyWareInfo ncpsyWareInfo)
    {
        startPage();
        List<NcpsyWareInfo> list = ncpsyWareInfoService.selectNcpsyWareInfoList(ncpsyWareInfo);
        return getDataTable(list);
    }

    /**
     * 导出仓储信息列表
     */
    @PreAuthorize("@ss.hasPermi('ncpsy:wareinfo:export')")
    @Log(title = "仓储信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, NcpsyWareInfo ncpsyWareInfo)
    {
        List<NcpsyWareInfo> list = ncpsyWareInfoService.selectNcpsyWareInfoList(ncpsyWareInfo);
        ExcelUtil<NcpsyWareInfo> util = new ExcelUtil<NcpsyWareInfo>(NcpsyWareInfo.class);
        util.exportExcel(response, list, "仓储信息数据");
    }

    /**
     * 获取仓储信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('ncpsy:wareinfo:query')")
    @GetMapping(value = "/{wareId}")
    public AjaxResult getInfo(@PathVariable("wareId") Long wareId)
    {
        return success(ncpsyWareInfoService.selectNcpsyWareInfoByWareId(wareId));
    }

    /**
     * 新增仓储信息
     */
    @PreAuthorize("@ss.hasPermi('ncpsy:wareinfo:add')")
    @Log(title = "仓储信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody NcpsyWareInfo ncpsyWareInfo)
    {
        return toAjax(ncpsyWareInfoService.insertNcpsyWareInfo(ncpsyWareInfo));
    }

    /**
     * 修改仓储信息
     */
    @PreAuthorize("@ss.hasPermi('ncpsy:wareinfo:edit')")
    @Log(title = "仓储信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody NcpsyWareInfo ncpsyWareInfo)
    {
        return toAjax(ncpsyWareInfoService.updateNcpsyWareInfo(ncpsyWareInfo));
    }

    /**
     * 删除仓储信息
     */
    @PreAuthorize("@ss.hasPermi('ncpsy:wareinfo:remove')")
    @Log(title = "仓储信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{wareIds}")
    public AjaxResult remove(@PathVariable Long[] wareIds)
    {
        return toAjax(ncpsyWareInfoService.deleteNcpsyWareInfoByWareIds(wareIds));
    }
}
